﻿using System;
using System.Collections.Generic;
using System.Text;
using WeatherApp.Base;

namespace WeatherApp
{
    /// <summary>
    /// 当前状况布告板
    /// </summary>
 public  class ForecastDisplay : IObserver, IDisplayElement
    {
        //_temp温度，_humidity湿度,pressure压力
        private float _temp, _humidity, _pressure;

        public ForecastDisplay(ISubject weatherData)
        {
            weatherData.RegisterObserver(this);
        }
        // 这个布告板只显示温度和湿度
        public void Display()
        {
            Console.WriteLine($"当前温度为：{_temp}℃");
            Console.WriteLine($"湿度为： {_humidity}%");
            Console.WriteLine($"气压：{_pressure}Bar");
            Console.WriteLine();
        }

        public void Update(float temp, float humidity, float pressure)
        {
            _temp = temp;
            _humidity = humidity;
            _pressure = pressure;
            Display();
        }
    }
}
